import threading
import time
import os


# 唱歌
def sing():
    for i in range(3):
        print("唱歌...")
        time.sleep(0.5)


# 跳舞
def dance():
    for i in range(3):
        print("跳舞...")
        time.sleep(0.5)

def sing_2(num: int = 3, name: str = "中国人"):
    for i in range(num):
        print("唱歌:{%s}..." % name)
        time.sleep(0.5)


# 跳舞
def dance_2(num: int = 3):
    for i in range(num):
        print("跳舞...")
        time.sleep(0.5)

def work():
    for i in range(10):
        print("work...")
        time.sleep(0.5)

if __name__ == '__main__':
    print("主进程开始执行...")
    # # 多进程，无参数
    # threading.Thread(target=sing).start()
    # threading.Thread(target=dance).start()

    # # 两种传参方式（位置参数，命名参数）
    # threading.Thread(target=sing_2, args=(3,)).start()
    # threading.Thread(target=dance_2, kwargs={'num': 4}).start()


    # # 主进程 会等待 非守护子进程执行完成 才结束
    # threading.Thread(target=work).start()
    # print('主进程完成执行')

    # 主进程 不等待 守护子进程执行完成
    # work_process = threading.Thread(target=work,daemon=True)
    # # work_process.daemon = True
    # # work_process.setDaemon(True)
    # print('主进程完成执行')


